using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Awesome.Extensions.String
{
    public static class StringEx
    {
        public static bool EqualsIgnoreCase(this string _this, string str)
        {
            // TODO: or we should use OrdinalCulture ?
            return str.Equals(str, StringComparison.InvariantCultureIgnoreCase);
        }

        public static int CompareIgnoreCase(this string _this, string str)
        {
            return System.String.Compare(_this, str, true);
        }

        private static readonly string[] NEW_LINES = new[] { "\r\n", "\n", "\r" };
        public static string[] SplitByNewLines(this string str)
        {
            return str.Split(NEW_LINES, StringSplitOptions.None);
        }

        public static IEnumerable<string> SkipEmpty(this IEnumerable<string> strings)
        {
            return strings.Where(s => s != string.Empty);
        }

        public static IEnumerable<string> SkipNullOrEmpty(this IEnumerable<string> strings)
        {
            return strings.Where(s => !System.String.IsNullOrEmpty(s));
        }


        public static void SetClipboard(this string str)
        {
            Clipboard.SetText(str, TextDataFormat.UnicodeText);
        }
    }
}